package cn.szzsi.business.service;

import com.jfinal.kit.HttpKit;
import com.jfinal.kit.StrKit;
import org.json.JSONObject;

/**
 * Created by admin on 2016/12/12.
 */
public class WeixinApiService {
    private static final String TOKEN_API = "https://test.yewyw.com/common/service/api/getAccessToken?apiid=%s";
    public static final WeixinApiService ts = new WeixinApiService();

    //由于只有这个客户需要分销，暂时先写死
    public String getToken(String apiid){
        if (StrKit.isBlank(apiid))
            apiid = "C1DFFAD80E4F467B3924BEE2F53ED139";
        String result= HttpKit.post(String.format(TOKEN_API,apiid),null,"");
        JSONObject jb = new JSONObject(result);
        if(jb.getBoolean("success")){
            JSONObject json=new JSONObject(result).getJSONObject("data");
            return json.get("access_token").toString();
        }
        return null;
    }
}
